Text Objects
Java programs typically handle text as Unicode strings, while the Mac OS platform uses special Mac OS-specific encodings (for example, MacRoman). To ensure compatibility, JManager functions pass all character strings as text objects. A text object is an object of typeJMTextRef
, and it encapsulates the string to pass along with its length and text encoding information. You can use other JManager functions to retrieve the encapsulated text as either a Unicode or a Mac OS encoding.For example, if you wanted to encapsulate the string "Happy days are here again" in a text object, you would call the
JMNewTextRef
function:
OSStatus JMNewTextRef ( myJavaSession, &myHappyRef, kTextEncodingMacRoman, "Happy days are here again", 25);TheJMNewTextRef
function requires you to specify the Java session that is to contain the text object (myJavaSession
in this example), the reference to use for the created object (myHappyRef
), the text encoding to use for the object (kTextEncodingMacRoman
), the string, and the length of the string (25 characters). You can specify any text encoding defined by the Text Encoding Converter; see the document Programming with the Text Encoding Converter Manager for a listing of possible encodings. After creating the text object, you would pass the referencemyHappyRef
anywhere you wanted to pass the string "Happy days are here again."After use, it is your responsibility to remove any text objects you created by calling the
JMDisposeTextRef
function . Any text objects passed by the session, however (for example, during a callback) are automatically removed when no longer required. For more information aboutJMNewTextRef
and other text object handling functions, see "Text Handling Functions".